{extend name="public/base" /} {block name="title"}
<title>友链管理</title>
{__block__}
<link href="//cdn.bootcss.com/datatables/1.10.15/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/iCheck/1.0.2/skins/all.css" rel="stylesheet">
<style>
    .editLink :hover,
    .delLink :hover {
        color: #000;
    }
</style>
<script>
    var indexLinkUrl = "{:url('admin/link/index')}"
    var addLinkUrl = "{:url('admin/link/add')}"
    var editLinkUrl = "{:url('admin/link/edit')}"
    var delLinkUrl = "{:url('admin/link/del')}"
    var changeStatusUrl = "{:url('admin/link/status')}"
</script>
{/block} {block name="page-heading"}
<div class="col-sm-4">
    <h2>友链管理</h2>
    <ol class="breadcrumb">
        <li>
            <a href="{:url('admin/index/home')}">主页</a>
        </li>
        <li>
            <strong>友链管理</strong>
        </li>
    </ol>
</div>
<div class="col-sm-8">
    <div class="title-action">
        <a data-toggle="modal" href="#addLinkModal" class="btn btn-primary">添加友链</a>
    </div>
</div> {/block} {block name="content"}
<table class="table linkTable table-striped table-hover table-condensed">
    <thead>
        <tr>
            <th></th>
            <th>友链名</th>
            <th>链接地址</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {foreach name="data" item="link"}
        <tr>
            <td>
                <input type="checkbox" value="{$link.id}" name="lid">
            </td>
            <td>{$link.name}</td>
            <td>{$link.url}</td>
            <td>
                <a href="javascript:void(0)" onclick="changeLinkStatus('{$link.id}','{$link.status}')">
                    {eq name="link.status" value='1'}隐藏
                        {else/}显示{/eq}
                </a>&nbsp;&nbsp;
                <a class="text-success editLink">
                    <i class="fa fa-pencil-square-o" ></i>
                </a>&nbsp;&nbsp;
                <a class="text-danger delLink">
                   <i class="fa fa-trash"></i>
                </a>
            </td>
        </tr>
        {/foreach}
    </tbody>
    <tfoot>
        <tr>
            <th></th>
            <th>友链名</th>
            <th>链接地址</th>
            <th>操作</th>
        </tr>
    </tfoot>
</table>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectAll('lid')">全选</a>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectEmpty('lid')">全不选</a>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectReverse('lid')">反选</a>
<a href="javascript:void(0)" class="btn btn-danger" id="delSelectedLink">删除选定</a> {/block} {block name="extra"}
<!--添加友链  -->
<div class="modal fade" id="addLinkModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="form-horizontal" role="form" id="addLinkForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">添加友链</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">友链名称</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" class="form-control" placeholder="请输入友链名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">友链URL</label>
                        <div class="col-sm-10">
                            <input type="text" name="url" class="form-control" placeholder="请输入友链URL">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否显示</label>
                        <div class="col-sm-10">
                            <label class="radio-inline i-checks"><input type="radio" value="1" id="status1" name="status" >&nbsp;&nbsp;是</label>
                            <label class="radio-inline i-checks"><input type="radio" value="0" id="status0" name="status" >&nbsp;&nbsp;否</label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--编辑友链  -->
<div class="modal fade" id="editLinkModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="form-horizontal" role="form" id="editLinkForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">编辑友链</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">友链名称</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" id="editName" class="form-control" placeholder="请输入友链名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">友链URL</label>
                        <div class="col-sm-10">
                            <input type="text" name="url" id="editUrl" class="form-control" placeholder="请输入友链URL">
                            <span class="help-block m-b-none text-danger">包括协议http/https</span>
                        </div>
                    </div>
                    <input type="hidden" name="id" id="editId">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div> {/block}{block name="script"}{__block__}
<script src="//cdn.bootcss.com/datatables/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="//cdn.bootcss.com/datatables/1.10.15/js/dataTables.bootstrap.min.js"></script>
<script src="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.js"></script>
<script src="//cdn.bootcss.com/iCheck/1.0.2/icheck.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/localization/messages_zh.min.js"></script>
<script src="__CUSTOME__/js/admin.validate.js"></script>
<script src="__CUSTOME__/js/admin.common.js"></script>
<script>
    $(function () {
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        });
        $(".linkTable").dataTable({
            language: {
                url: "__PLUGINS__/dataTables/Chinese.json"
            },
            "columns": [{
                "orderable": false
            }, null, null, {
                "orderable": false
            }, ],
        });

    });
</script> {/block}